<?
class objSoftware {
	public $index = 0;
	public $manufacturer = ''; 
	public $type = '';
	public $name = '';
	public $installed  = 0;
	public function __construct($fields=array()) {
		if (is_object($fields) || is_array($fields)) {
			foreach ($fields AS $name=>$value) {
				switch ($name) {
					case 'hrSWInstalledDate':
						$this->installed = strtotime($value);
						break;
					case 'hrSWInstalledName':
						$this->name = $value;
						break;
					case 'hrSWInstalledIndex':
						$this->index = $value;
						break;
				}
			}
		}
		// Determine Manufacturer
		$this->determineManufacturer();
		
		$this->determineType();
	}
	
	
	protected function determineManufacturer() {
		if (preg_match('/Microsoft/',$this->name) || preg_match('/\(KB([0-9a-z-]+)\)/',$this->name) || preg_match('/Internet Explorer/',$this->name)) {
			$this->manufacturer = 'Microsoft';
		} elseif (preg_match('/Adobe/',$this->name)) {
			$this->manufacturer = 'Adobe';
		}
	
	}

	protected function determineType() {
		if (preg_match('/\(KB([0-9a-z-]+)\)/',$this->name)) {
			$this->type='Windows Update';
		} elseif (preg_match('/Driver/',$this->name)) {
			$this->type = 'Driver';
		}
	}

}